import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: localStorage.getItem("token"),
    userInfo: JSON.parse(localStorage.getItem("userInfo")), 
  },
  mutations: {
    setToken(state, val) {
      state.token = val;
      localStorage.setItem("token", val);
    },
    setUserInfo(state, val) {
      localStorage.setItem("userInfo", val);
    },
  }
})
